function fmoney(s, n) //s:传入的float数字 ，n:希望返回小数点几位 
{
    n = n > 0 && n <= 20 ? n : 2;
    s = parseFloat((s + "").replace(/[^\d\.-]/g, "")).toFixed(n) + "";
    var l = s.split(".")[0].split("").reverse(),
        r = s.split(".")[1];
    t = "";
    for (i = 0; i < l.length; i++) {
        t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? "," : "");
    }
    return t.split("").reverse().join("") + "." + r;
}
window.onresize = function() {
    myresize()
};
var myresize = function() {
    console.log(1);
    $("#test-upload-drag").css("height", $("#more_img_list").width() / 3 + "px");
    $("#more_img_list>div>div").css("height", $("#more_img_list").width() / 3 + "px");
};
var onmyClick = function(obj) {
    $(obj).parent().removeClass("my-all-check");
    if (obj.checked) {
        $(obj).parent().addClass("my-all-check");
    }
}
var initget = function() {
    $(".number").focusout(function() {
        $(this).val(fmoney($(this).val(), 2));
    })
    new Sortable(document.getElementById('more_img_list'), {
        animation: 150,
        handle: '.my-handle',
        ghostClass: 'blue-background-class'
    });
    $("#test-upload-drag").css("height", $("#more_img_list").width() / 3 + "px");
    layui.use(['upload', 'form'], function() {
        var form = layui.form;
        var upload = layui.upload;
        form.on('checkbox(haveshopping)', function(data) {
            if (data.elem.checked) {
                $(".hasshopping").show();
                $(".noshopping").hide();
            } else {
                $(".hasshopping").hide();
                $(".noshopping").show();
            }
        });
        //拖拽上传
        upload.render({
            elem: '#test-upload-drag',
            url: '/manage/business/common/upload.html?Directory=id3P7CECLN8%3D',
            multiple: true,
            done: function(res) {
                var svg = '<svg t="1657003356688" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2937" width="30" height="30"><path d="M486.4 776.533333v-213.333333H247.466667v106.666667L85.333333 512l162.133334-162.133333V512h238.933333V247.466667H349.866667L512 85.333333l162.133333 162.133334h-132.266666V512h238.933333V349.866667L938.666667 512l-162.133334 162.133333v-106.666666h-238.933333v213.333333h132.266667L512 938.666667l-162.133333-162.133334h136.533333z" p-id="2938" fill="#ffffff"></path></svg>';
                $("#more_img_list").prepend("<div class='layui-col-xs4' ><div style='height:" + $("#more_img_list").width() / 3 + "px'><div class='my-all'><div class='bg-move'></div><input type='checkbox' class='my-check' onclick='onmyClick(this)' /><div class='my-handle'>" + svg + "</div></div><img class='' src='" + res.files[0].url + "' /></div></div>");
            }
        });
    });

}

// 主入口文件
var pjson = {};
$(function() {
    layui.config({
        version: '2015010514941530',
        base: 'http://shop120.oss-cn-shenzhen.aliyuncs.com/static/business/manage/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index'], function() {
        if (typeof(initfun) != "undefined") {
            initfun();
        }
        if (top.basetop) {
            top.closeloadTip();
        }
    });
})